<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: table_common_admincp_cmenu.php 27806 2012-02-15 03:20:46Z svn_project_zhangjie $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

class table_home_videocate extends discuz_table
{
	public function __construct() {

		$this->_table = 'home_video_cate';
		$this->_pk    = 'cate_id';

		parent::__construct();
	}

	public function get_all_cate(){
		return  DB::fetch_all('select * from %t order by cate_sort',array($this->_table));
	}

	public function get_cate_by_id($id){
		return DB::fetch_first('select * from %t where cate_id=%d',array($this->_table,$id));
	}

	public function add_videocate($cate_name,$cate_sort,$add_time){
		return DB::query('insert into %t (cate_name,cate_sort,add_time) values(%s,%s,%s)',array($this->_table,$cate_name,$cate_sort,$add_time));
	}

	public function update_cate($pid,$opt,$name,$sort){
		if(isset($opt)){
			return DB::query('delete from %t where cate_id=%d',array($this->_table,$pid));
		} else{
			if($name != '' && $sort != ''){
				return DB::query('update %t set cate_name=%s,cate_sort=%d where cate_id=%d', array($this->_table,$name,$sort,$pid));
			}elseif($name != '' && $sort == ''){
				return DB::query('update %t set cate_name=%s where cate_id=%d', array($this->_table,$name,$pid));
			}elseif($name == '' && $sort != ''){
				return DB::query('update %t set cate_sort=%d where cate_id=%d', array($this->_table,$sort,$pid));
			}
		}
	}

}

?>